﻿using Microsoft.AspNetCore.Mvc;

namespace WebApi.Controllers
{
    [Route("[controller]")]
    [ApiController]
    [ApiExplorerSettings(GroupName = nameof(ApiVersions.V2))]
    public class FirstV2Controller : ControllerBase
    {
        private readonly ILogger<FirstController> _logger;

        public FirstV2Controller(ILogger<FirstController> logger)
        {
            _logger = logger;
        }

        /// <summary>
        /// 使用HTTP GET获取数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IEnumerable<String> GetStrings()
        {
            return Enumerable.Range(1, 5).Select(r => Random.Shared.NextSingle().ToString());
        }

        /// <summary>
        /// 使用HTTP POST接口
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public IEnumerable<String> PostStrings()
        {
            return Enumerable.Range(1, 5).Select(r => Random.Shared.NextSingle().ToString());
        }

        /// <summary>
        /// 使用HTTP PUT接口
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        public IEnumerable<String> PutStrings()
        {
            return Enumerable.Range(1, 5).Select(r => Random.Shared.NextSingle().ToString());
        }

        /// <summary>
        /// 使用HTTP PATCH接口
        /// </summary>
        /// <returns></returns>
        [HttpPatch]
        public IEnumerable<String> PatchStrings()
        {
            return Enumerable.Range(1, 5).Select(r => Random.Shared.NextSingle().ToString());
        }

        /// <summary>
        /// 使用HTTP DELETE接口
        /// </summary>
        /// <returns></returns>
        [HttpDelete]
        public IEnumerable<String> DeleteStrings()
        {
            return Enumerable.Range(1, 5).Select(r => Random.Shared.NextSingle().ToString());
        }
    }
}
